package o;

import com.huawei.appgallery.festivalanimation.particle.modifiers.SizeModifier;
import java.util.Arrays;
import java.util.HashMap;
import o.eo.a;

public class ea {
    public static ei ʻ;
    private static int ᐝ = 1000;
    private final d ʻॱ;
    private d ʼ;
    private HashMap<String, eh> ʽ;
    public boolean ˊ;
    private int ˊॱ;
    int ˋ;
    private int ˋॱ;
    ec[] ˎ;
    int ˏ;
    private eh[] ˏॱ;
    private int ͺ;
    int ॱ;
    private boolean[] ॱˊ;
    final ee ॱॱ;
    private ec[] ॱᐝ;
    private int ᐝॱ;

    interface d {
        eh ʼ();

        void ʽ();

        eh ˊ(ea eaVar, boolean[] zArr);

        void ˊ(d dVar);

        void ˊ(eh ehVar);
    }

    public ea() {
        this.ˏ = 0;
        this.ʽ = null;
        this.ͺ = 32;
        this.ˊॱ = this.ͺ;
        this.ˎ = null;
        this.ˊ = false;
        this.ॱˊ = new boolean[this.ͺ];
        this.ˋ = 1;
        this.ॱ = 0;
        this.ˋॱ = this.ͺ;
        this.ˏॱ = new eh[ᐝ];
        this.ᐝॱ = 0;
        this.ॱᐝ = new ec[this.ͺ];
        this.ˎ = new ec[this.ͺ];
        ʽ();
        this.ॱॱ = new ee();
        this.ʼ = new ed(this.ॱॱ);
        this.ʻॱ = new ec(this.ॱॱ);
    }

    public static ei ˏ() {
        return ʻ;
    }

    private void ʻ() {
        this.ͺ *= 2;
        this.ˎ = (ec[]) Arrays.copyOf(this.ˎ, this.ͺ);
        this.ॱॱ.ˎ = (eh[]) Arrays.copyOf(this.ॱॱ.ˎ, this.ͺ);
        this.ॱˊ = new boolean[this.ͺ];
        this.ˊॱ = this.ͺ;
        this.ˋॱ = this.ͺ;
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ˎ++;
            ʻ.ʻॱ = Math.max(ʻ.ʻॱ, (long) this.ͺ);
            ʻ.ˉ = ʻ.ʻॱ;
        }
    }

    private void ʽ() {
        for (int i = 0; i < this.ˎ.length; i++) {
            Object obj = this.ˎ[i];
            if (obj != null) {
                this.ॱॱ.ˋ.ˊ(obj);
            }
            this.ˎ[i] = null;
        }
    }

    public void ॱ() {
        int i;
        for (eh ehVar : this.ॱॱ.ˎ) {
            if (ehVar != null) {
                ehVar.ˎ();
            }
        }
        this.ॱॱ.ˏ.ˊ(this.ˏॱ, this.ᐝॱ);
        this.ᐝॱ = 0;
        Arrays.fill(this.ॱॱ.ˎ, null);
        if (this.ʽ != null) {
            this.ʽ.clear();
        }
        this.ˏ = 0;
        this.ʼ.ʽ();
        this.ˋ = 1;
        for (i = 0; i < this.ॱ; i++) {
            this.ˎ[i].ॱ = false;
        }
        ʽ();
        this.ॱ = 0;
    }

    public eh ˊ(Object obj) {
        eh ehVar = null;
        if (obj != null) {
            if (this.ˋ + 1 >= this.ˊॱ) {
                ʻ();
            }
            if (obj instanceof eo) {
                ehVar = ((eo) obj).ˋ();
                if (ehVar == null) {
                    ((eo) obj).ˎ(this.ॱॱ);
                    ehVar = ((eo) obj).ˋ();
                }
                if (ehVar.ˋ == -1 || ehVar.ˋ > this.ˏ || this.ॱॱ.ˎ[ehVar.ˋ] == null) {
                    if (ehVar.ˋ != -1) {
                        ehVar.ˎ();
                    }
                    this.ˏ++;
                    this.ˋ++;
                    ehVar.ˋ = this.ˏ;
                    ehVar.ʽ = o.eh.d.UNRESTRICTED;
                    this.ॱॱ.ˎ[this.ˏ] = ehVar;
                }
            }
        }
        return ehVar;
    }

    public ec ˊ() {
        ec ecVar = (ec) this.ॱॱ.ˋ.ॱ();
        if (ecVar == null) {
            ecVar = new ec(this.ॱॱ);
        } else {
            ecVar.ˎ();
        }
        eh.ˏ();
        return ecVar;
    }

    public eh ˋ() {
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ˏॱ++;
        }
        if (this.ˋ + 1 >= this.ˊॱ) {
            ʻ();
        }
        eh ˊ = ˊ(o.eh.d.SLACK, null);
        this.ˏ++;
        this.ˋ++;
        ˊ.ˋ = this.ˏ;
        this.ॱॱ.ˎ[this.ˏ] = ˊ;
        return ˊ;
    }

    public eh ˎ() {
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ͺ++;
        }
        if (this.ˋ + 1 >= this.ˊॱ) {
            ʻ();
        }
        eh ˊ = ˊ(o.eh.d.SLACK, null);
        this.ˏ++;
        this.ˋ++;
        ˊ.ˋ = this.ˏ;
        this.ॱॱ.ˎ[this.ˏ] = ˊ;
        return ˊ;
    }

    private void ˎ(ec ecVar) {
        ecVar.ˋ(this, 0);
    }

    void ॱ(ec ecVar, int i, int i2) {
        ecVar.ˏ(ˋ(i2, null), i);
    }

    public eh ˋ(int i, String str) {
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ˊॱ++;
        }
        if (this.ˋ + 1 >= this.ˊॱ) {
            ʻ();
        }
        eh ˊ = ˊ(o.eh.d.ERROR, str);
        this.ˏ++;
        this.ˋ++;
        ˊ.ˋ = this.ˏ;
        ˊ.ˏ = i;
        this.ॱॱ.ˎ[this.ˏ] = ˊ;
        this.ʼ.ˊ(ˊ);
        return ˊ;
    }

    private eh ˊ(o.eh.d dVar, String str) {
        eh ehVar;
        eh ehVar2 = (eh) this.ॱॱ.ˏ.ॱ();
        if (ehVar2 == null) {
            ehVar2 = new eh(dVar, str);
            ehVar2.ˏ(dVar, str);
            ehVar = ehVar2;
        } else {
            ehVar2.ˎ();
            ehVar2.ˏ(dVar, str);
            ehVar = ehVar2;
        }
        if (this.ᐝॱ >= ᐝ) {
            ᐝ *= 2;
            this.ˏॱ = (eh[]) Arrays.copyOf(this.ˏॱ, ᐝ);
        }
        eh[] ehVarArr = this.ˏॱ;
        int i = this.ᐝॱ;
        this.ᐝॱ = i + 1;
        ehVarArr[i] = ehVar;
        return ehVar;
    }

    public int ॱ(Object obj) {
        eh ˋ = ((eo) obj).ˋ();
        if (ˋ != null) {
            return (int) (ˋ.ˎ + 0.5f);
        }
        return 0;
    }

    public void ʼ() throws Exception {
        Object obj = null;
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ˊ++;
        }
        if (this.ˊ) {
            if (ʻ != null) {
                eiVar = ʻ;
                eiVar.ॱᐝ++;
            }
            for (int i = 0; i < this.ॱ; i++) {
                if (!this.ˎ[i].ˏ) {
                    break;
                }
            }
            int i2 = 1;
            if (obj == null) {
                ˋ(this.ʼ);
                return;
            }
            if (ʻ != null) {
                eiVar = ʻ;
                eiVar.ᐝॱ++;
            }
            ॱॱ();
            return;
        }
        ˋ(this.ʼ);
    }

    void ˋ(d dVar) throws Exception {
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ॱˋ++;
            ʻ.ʿ = Math.max(ʻ.ʿ, (long) this.ˋ);
            ʻ.ʼॱ = Math.max(ʻ.ʼॱ, (long) this.ॱ);
        }
        ॱ((ec) dVar);
        ˎ(dVar);
        ˊ(dVar, false);
        ॱॱ();
    }

    private final void ॱ(ec ecVar) {
        if (this.ॱ > 0) {
            ecVar.ˋ.ˎ(ecVar, this.ˎ);
            if (ecVar.ˋ.ˎ == 0) {
                ecVar.ˏ = true;
            }
        }
    }

    public void ˏ(ec ecVar) {
        boolean z = true;
        if (ecVar != null) {
            if (ʻ != null) {
                ei eiVar = ʻ;
                eiVar.ʽ++;
                if (ecVar.ˏ) {
                    eiVar = ʻ;
                    eiVar.ॱॱ++;
                }
            }
            if (this.ॱ + 1 >= this.ˋॱ || this.ˋ + 1 >= this.ˊॱ) {
                ʻ();
            }
            if (ecVar.ˏ) {
                z = false;
            } else {
                ॱ(ecVar);
                if (!ecVar.ˋ()) {
                    ecVar.ॱ();
                    if (ecVar.ˎ(this)) {
                        eh ˎ = ˎ();
                        ecVar.ˎ = ˎ;
                        ˊ(ecVar);
                        this.ʻॱ.ˊ((d) ecVar);
                        ˊ(this.ʻॱ, true);
                        if (ˎ.ॱ == -1) {
                            if (ecVar.ˎ == ˎ) {
                                ˎ = ecVar.ˏ(ˎ);
                                if (ˎ != null) {
                                    if (ʻ != null) {
                                        ei eiVar2 = ʻ;
                                        eiVar2.ᐝ++;
                                    }
                                    ecVar.ˎ(ˎ);
                                }
                            }
                            if (!ecVar.ˏ) {
                                ecVar.ˎ.ˋ(ecVar);
                            }
                            this.ॱ--;
                        }
                    } else {
                        z = false;
                    }
                    if (!ecVar.ˏ()) {
                        return;
                    }
                }
                return;
            }
            if (!z) {
                ˊ(ecVar);
            }
        }
    }

    private final void ˊ(ec ecVar) {
        if (this.ˎ[this.ॱ] != null) {
            this.ॱॱ.ˋ.ˊ(this.ˎ[this.ॱ]);
        }
        this.ˎ[this.ॱ] = ecVar;
        ecVar.ˎ.ॱ = this.ॱ;
        this.ॱ++;
        ecVar.ˎ.ˋ(ecVar);
    }

    private final int ˊ(d dVar, boolean z) {
        int i;
        if (ʻ != null) {
            ei eiVar = ʻ;
            eiVar.ʼ++;
        }
        Object obj = null;
        for (i = 0; i < this.ˋ; i++) {
            this.ॱˊ[i] = false;
        }
        i = 0;
        while (obj == null) {
            if (ʻ != null) {
                ei eiVar2 = ʻ;
                eiVar2.ʻ++;
            }
            int i2 = i + 1;
            if (i2 >= this.ˋ * 2) {
                return i2;
            }
            Object obj2;
            if (dVar.ʼ() != null) {
                this.ॱˊ[dVar.ʼ().ˋ] = true;
            }
            eh ˊ = dVar.ˊ(this, this.ॱˊ);
            if (ˊ != null) {
                if (this.ॱˊ[ˊ.ˋ]) {
                    return i2;
                }
                this.ॱˊ[ˊ.ˋ] = true;
            }
            if (ˊ != null) {
                float f = Float.MAX_VALUE;
                int i3 = -1;
                for (i = 0; i < this.ॱ; i++) {
                    ec ecVar = this.ˎ[i];
                    if (!(ecVar.ˎ.ʽ == o.eh.d.UNRESTRICTED || ecVar.ˏ || !ecVar.ॱ(ˊ))) {
                        float ˊ2 = ecVar.ˋ.ˊ(ˊ);
                        if (ˊ2 < 0.0f) {
                            float f2 = (-ecVar.ˊ) / ˊ2;
                            if (f2 < f) {
                                i3 = i;
                                f = f2;
                            }
                        }
                    }
                }
                if (i3 > -1) {
                    ec ecVar2 = this.ˎ[i3];
                    ecVar2.ˎ.ॱ = -1;
                    if (ʻ != null) {
                        ei eiVar3 = ʻ;
                        eiVar3.ᐝ++;
                    }
                    ecVar2.ˎ(ˊ);
                    ecVar2.ˎ.ॱ = i3;
                    ecVar2.ˎ.ˋ(ecVar2);
                    obj2 = obj;
                } else {
                    obj2 = 1;
                }
            } else {
                obj2 = 1;
            }
            obj = obj2;
            i = i2;
        }
        return i;
    }

    private int ˎ(d dVar) throws Exception {
        Object obj;
        int i = 0;
        while (i < this.ॱ) {
            if (this.ˎ[i].ˎ.ʽ != o.eh.d.UNRESTRICTED && this.ˎ[i].ˊ < 0.0f) {
                obj = 1;
                break;
            }
            i++;
        }
        obj = null;
        if (obj == null) {
            return 0;
        }
        Object obj2 = null;
        i = 0;
        while (obj2 == null) {
            if (ʻ != null) {
                ei eiVar = ʻ;
                eiVar.ˋॱ++;
            }
            int i2 = i + 1;
            float f = Float.MAX_VALUE;
            int i3 = 0;
            int i4 = -1;
            int i5 = -1;
            for (i = 0; i < this.ॱ; i++) {
                ec ecVar = this.ˎ[i];
                if (!(ecVar.ˎ.ʽ == o.eh.d.UNRESTRICTED || ecVar.ˏ || ecVar.ˊ >= 0.0f)) {
                    float f2 = f;
                    int i6 = i3;
                    i3 = i4;
                    i4 = i5;
                    for (i5 = 1; i5 < this.ˋ; i5++) {
                        eh ehVar = this.ॱॱ.ˎ[i5];
                        float ˊ = ecVar.ˋ.ˊ(ehVar);
                        if (ˊ > 0.0f) {
                            float f3 = f2;
                            int i7 = 0;
                            while (i7 < 7) {
                                float f4 = ehVar.ˊ[i7] / ˊ;
                                if ((f4 >= f3 || i7 != r4) && i7 <= r4) {
                                    f4 = f3;
                                } else {
                                    i4 = i5;
                                    i3 = i;
                                    i6 = i7;
                                }
                                i7++;
                                f3 = f4;
                            }
                            f2 = f3;
                        }
                    }
                    i5 = i4;
                    i4 = i3;
                    i3 = i6;
                    f = f2;
                }
            }
            if (i4 != -1) {
                ec ecVar2 = this.ˎ[i4];
                ecVar2.ˎ.ॱ = -1;
                if (ʻ != null) {
                    ei eiVar2 = ʻ;
                    eiVar2.ᐝ++;
                }
                ecVar2.ˎ(this.ॱॱ.ˎ[i5]);
                ecVar2.ˎ.ॱ = i4;
                ecVar2.ˎ.ˋ(ecVar2);
                obj = obj2;
            } else {
                obj = 1;
            }
            if (i2 > this.ˋ / 2) {
                obj = 1;
            }
            obj2 = obj;
            i = i2;
        }
        return i;
    }

    private void ॱॱ() {
        for (int i = 0; i < this.ॱ; i++) {
            ec ecVar = this.ˎ[i];
            ecVar.ˎ.ˎ = ecVar.ˊ;
        }
    }

    public ee ᐝ() {
        return this.ॱॱ;
    }

    public void ˋ(eh ehVar, eh ehVar2, int i, int i2) {
        ec ˊ = ˊ();
        eh ˋ = ˋ();
        ˋ.ˏ = 0;
        ˊ.ˊ(ehVar, ehVar2, ˋ, i);
        if (i2 != 6) {
            ॱ(ˊ, (int) (ˊ.ˋ.ˊ(ˋ) * SizeModifier.STABLE_STATE_SCALE), i2);
        }
        ˏ(ˊ);
    }

    public void ˏ(eh ehVar, eh ehVar2, boolean z) {
        ec ˊ = ˊ();
        eh ˋ = ˋ();
        ˋ.ˏ = 0;
        ˊ.ˊ(ehVar, ehVar2, ˋ, 0);
        if (z) {
            ॱ(ˊ, (int) (ˊ.ˋ.ˊ(ˋ) * SizeModifier.STABLE_STATE_SCALE), 1);
        }
        ˏ(ˊ);
    }

    public void ॱ(eh ehVar, eh ehVar2, int i, int i2) {
        ec ˊ = ˊ();
        eh ˋ = ˋ();
        ˋ.ˏ = 0;
        ˊ.ॱ(ehVar, ehVar2, ˋ, i);
        if (i2 != 6) {
            ॱ(ˊ, (int) (ˊ.ˋ.ˊ(ˋ) * SizeModifier.STABLE_STATE_SCALE), i2);
        }
        ˏ(ˊ);
    }

    public void ˎ(eh ehVar, eh ehVar2, boolean z) {
        ec ˊ = ˊ();
        eh ˋ = ˋ();
        ˋ.ˏ = 0;
        ˊ.ॱ(ehVar, ehVar2, ˋ, 0);
        if (z) {
            ॱ(ˊ, (int) (ˊ.ˋ.ˊ(ˋ) * SizeModifier.STABLE_STATE_SCALE), 1);
        }
        ˏ(ˊ);
    }

    public void ˎ(eh ehVar, eh ehVar2, int i, float f, eh ehVar3, eh ehVar4, int i2, int i3) {
        ec ˊ = ˊ();
        ˊ.ॱ(ehVar, ehVar2, i, f, ehVar3, ehVar4, i2);
        if (i3 != 6) {
            ˊ.ˋ(this, i3);
        }
        ˏ(ˊ);
    }

    public void ˋ(eh ehVar, eh ehVar2, eh ehVar3, eh ehVar4, float f, int i) {
        ec ˊ = ˊ();
        ˊ.ˎ(ehVar, ehVar2, ehVar3, ehVar4, f);
        if (i != 6) {
            ˊ.ˋ(this, i);
        }
        ˏ(ˊ);
    }

    public ec ˊ(eh ehVar, eh ehVar2, int i, int i2) {
        ec ˊ = ˊ();
        ˊ.ˎ(ehVar, ehVar2, i);
        if (i2 != 6) {
            ˊ.ˋ(this, i2);
        }
        ˏ(ˊ);
        return ˊ;
    }

    public void ˋ(eh ehVar, int i) {
        int i2 = ehVar.ॱ;
        ec ecVar;
        if (ehVar.ॱ != -1) {
            ecVar = this.ˎ[i2];
            if (ecVar.ˏ) {
                ecVar.ˊ = (float) i;
                return;
            } else if (ecVar.ˋ.ˎ == 0) {
                ecVar.ˏ = true;
                ecVar.ˊ = (float) i;
                return;
            } else {
                ecVar = ˊ();
                ecVar.ˋ(ehVar, i);
                ˏ(ecVar);
                return;
            }
        }
        ecVar = ˊ();
        ecVar.ˊ(ehVar, i);
        ˏ(ecVar);
    }

    public static ec ˏ(ea eaVar, eh ehVar, eh ehVar2, eh ehVar3, float f, boolean z) {
        ec ˊ = eaVar.ˊ();
        if (z) {
            eaVar.ˎ(ˊ);
        }
        return ˊ.ˊ(ehVar, ehVar2, ehVar3, f);
    }

    public void ˏ(el elVar, el elVar2, float f, int i) {
        eh ˊ = ˊ(elVar.ˎ(a.LEFT));
        eh ˊ2 = ˊ(elVar.ˎ(a.TOP));
        eh ˊ3 = ˊ(elVar.ˎ(a.RIGHT));
        eh ˊ4 = ˊ(elVar.ˎ(a.BOTTOM));
        eh ˊ5 = ˊ(elVar2.ˎ(a.LEFT));
        eh ˊ6 = ˊ(elVar2.ˎ(a.TOP));
        eh ˊ7 = ˊ(elVar2.ˎ(a.RIGHT));
        eh ˊ8 = ˊ(elVar2.ˎ(a.BOTTOM));
        ec ˊ9 = ˊ();
        ˊ9.ˊ(ˊ2, ˊ4, ˊ6, ˊ8, (float) (Math.sin((double) f) * ((double) i)));
        ˏ(ˊ9);
        ˊ9 = ˊ();
        ˊ9.ˊ(ˊ, ˊ3, ˊ5, ˊ7, (float) (Math.cos((double) f) * ((double) i)));
        ˏ(ˊ9);
    }
}
